package com.itheima.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.dao.BookDao;
import com.itheima.domain.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @author tongchen
 * @create 2022-12-20 21:16
 */
@Component
public class IBookServiceImpl implements IBookService {
    @Autowired
    BookDao bookDao;
    @Override
    public boolean save(Book book) {
        return bookDao.insert(book)>0;
    }

    @Override
    @Cacheable(value = "cacheSpace",key = "#id")
    public Book selectById(Integer id) {
        return bookDao.selectById(id);
    }
}
